package online.niuma.xiaocubao.controller;

import online.niuma.xiaocubao.pojo.params.AddArticleParam;
import online.niuma.xiaocubao.pojo.vo.Result;
import online.niuma.xiaocubao.service.IArticleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 一颗蛋50斤
 * @since 2022-11-12
 */
@RestController
@RequestMapping("/article")
public class ArticleController {

    @Resource
    private IArticleService articleService;

    @PostMapping("/addArticle")
    public Result addArticle(@RequestBody AddArticleParam addArticleParam) {
        return articleService.addArticle(addArticleParam);
    }

    @GetMapping("/getArticleAllInfoByUser")
    public Result getArticleAllInfoByUser() {
        return  articleService.queryArticleInfoAllByUser();
    }

    @GetMapping("/getArticleById/{articleId}")
    public Result getArticleById(@PathVariable("articleId") Long articleId) {
        return articleService.getArticleById(articleId);
    }

}
